package ru.st.selenium.applogic2;

import java.util.List;

import org.openqa.selenium.WebElement;
import ru.st.selenium.applogic.FilmHelper;
import ru.st.selenium.model.Film;

public class FilmHelper2 extends DriverBasedHelper implements FilmHelper {

  public FilmHelper2(ApplicationManager2 manager) {
    super(manager.getWebDriver());
  }

  @Override
  public void create(Film film) {
    pages.homePage
            .clickNewMovieBtn().ensurePageLoaded()
            .setTitle(film.getTitle())
            .setDuration(film.getDuration())
            .setYear(film.getYear())
            .setAlsoKnown(film.getAlsoKnown())
//            .setImdbNumber(film.getImdb())
            .clickSubmit();
  }

  @Override
  public void delete(String title) {
    pages.homePage.openFilmPage(title);
    pages.simpleMoviePage.removeMovie();
  }

  @Override
  public List<Film> search(String title) {
    return null;
  }

    @Override
    public boolean isCreated(Film film) {
        return false;
    }

    @Override
    public String getCurrentFilmTitle() {
       return pages.simpleMoviePage.getMovieName();
    }

    @Override
    public String getYearAlert() {
        return pages.newMoviePage.getYearAlertText();
    }

    @Override
    public int sizeOfAllFoundMovies() {
        return pages.homePage.getSizeOffAllMoviesList();
    }

    @Override
    public String getResultAlertText() {
        return pages.homePage.getResult();
    }

    @Override
    public int getSizeBeforeCreatingNewFilm() {  return pages.homePage.getSizeOffAllMoviesList(); }

    @Override
    public int getSizeAfterCreatingNewFilm() {
        return pages.homePage.getSizeOffAllMoviesList();
    }

    @Override
    public void searchForMovie(String title) {
        pages.homePage.searchForMovie(title);
    }

//    private Film getNewCreatedFilm() {
//        pages.homePage.ensurePageLoaded().clickOnSimpleMovie();
//    }

}
